<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>老人管理-老人信息-个性化设置</title>
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<link href="/layertwo-assets/css/bootstrap.min.css" rel="stylesheet">
	<link href="/layertwo-assets/css/style.css" rel="stylesheet">
	<link href="/layertwo-assets/css/font-awesome.css" rel="stylesheet">
    <link rel="stylesheet" href="/plugins/SweetAlert/sweetalert.css" />
</head>
<body>
	<div class="container-fluid">
		<div class="om-ctl-mes">
			<div class="title">
				<div class="col-xs-12"><span class="fa fa-list-ul"> 老人管理</span><b class="fa fa-caret-right"></b><i><a href="../老人信息.html">老人信息</a></i><b class="fa fa-caret-right"></b><i>个性化设置</i></div>
			</div>
            <div class="personset-content col-xs-12">
                <div id="personset-tab-list" class="col-xs-2">
                   <span>早上</span>
                   <span>上午</span>
                   <span>中午</span>
                   <span>下午</span>
                   <span>晚上</span>
                   <span>喝水</span>
                   <span>翻身</span>
              </div>
              <div id="personset-tab-content" class="col-xs-10">
                  <div>
                    <form method="post" class="myform">
                      <table class="table table-condensed">
                      <thead>
                        <tr>
                          <th>护理类型</th>
                          <th>是否显示</th>
                          <th>是否提醒</th>
                          <th>提醒日期</th>
                          <th>提醒时间</th>
                          <th>提醒方式</th>
                          <th>提醒内容</th>
                        </tr>
                     </thead>
                     <tbody>
                      <?foreach($tPIDatas as $tPIRow){?>
                       <tr>  
                          <td><input type="hidden" name="<?=$tPIRow['num']?>"><input type="hidden" name="at" value="1">
                          <input type="hidden" name="pi_id[]" value="<?=$tPIRow['pi_id']?>"><?=$tPIRow['name']?></td>
                          <!--<td><input type="radio" name="is_show[]"><label>是</label><input type="radio" name="is_show[]"><label>否</label></td>-->
                          <td><select name="is_show[]" style="width:80px;"><option value="1" <?if($tPIRow['is_show'] == 1){echo 'selected';}?>>是</option><option value="2" <?if($tPIRow['is_show'] == 2){echo 'selected';}?>>否</option></select></td>
                          <td><select name="status[]" style="width:80px;"><option value="1" <?if($tPIRow['status'] == 1){echo 'selected';}?>>否</option><option value="2" <?if($tPIRow['status'] == 2){echo 'selected';}?>>是</option></select></td>
                          <!--<td><input type="radio" name="status[]"><label>是</label><input type="radio" name="status[]"><label>否</label></td>-->
                          <td><input type="text" style="width:100px;" onclick="WdatePicker()"name="startdate[]" value="<?=$tPIRow['startdate']?>" readonly="readonly"><small></small><input type="text" style="width:100px;" onclick="WdatePicker()"name="enddate[]" value="<?=$tPIRow['enddate']?>" readonly="readonly"></td>
                          <td><input type="text" style="width:100px;" name="respondtime[]" onclick="WdatePicker({dateFmt:'HH:mm',skin:'whyGreen',quickSel:['<?=date('H:i',(time()+30*60))?>','<?=date('H:i',(time()+60*60))?>','<?=date('H:i',(time()+90*60))?>','<?=date('H:i',(time()+120*60))?>','<?=date('H:i',(time()+150*60))?>']})"value="<?=$tPIRow['respond_time']?>" readonly="readonly"/></td>
                          <td><select name="remind_type[]" style="width: 50px">
                                <option value="">选择提醒方式</option>
                                <option value="1" <?if($tPIRow['plan_type'] == 1){echo 'selected';}?>>铃声</option>
                                <option value="2" <?if($tPIRow['plan_type'] == 2){echo 'selected';}?>>震动</option>
                                </select></td>
                          <td><input type="text" name="descriptions[]" value="<?=empty($tPIRow['description'])?$tPIRow['descriptions']:$tPIRow['description']?>"/></td>
                        </tr>
                        <?}?>
                     </tbody>
                 </table>
                </form>
                  </div>
                  <div>
                     <form method="post" class="myfrom"> 
                      <table class="table table-condensed">
                      <thead>
                        <tr>
                          <th>护理类型</th>
                          <th>是否显示</th>
                          <th>是否提醒</th>
                          <th>提醒日期</th>
                          <th>提醒时间</th>
                          <th>提醒方式</th>
                          <th>提醒内容</th>
                        </tr>
                     </thead>
                     <tbody>
                      <?foreach($tPIDatas1 as $tPI1Row){?>
                       <tr>
                          <td><?=$tPI1Row['name']?><input type="hidden" name="at" value="2"><input type="hidden" name="<?=$tPI1Row['num']?>"><input type="hidden" name="pi_id[]" value="<?=$tPI1Row['pi_id']?>"></td>
                          <td><select name="is_show[]" style="width:80px;"><option value="1" <?if($tPI1Row['is_show'] == 1){echo 'selected';}?>>是</option><option value="2" <?if($tPI1Row['is_show'] == 2){echo 'selected';}?>>否</option></select></td>
                          <td><select name="status[]" style="width:80px;"><option value="1" <?if($tPI1Row['status'] == 1){echo 'selected';}?>>否</option><option value="2" <?if($tPI1Row['status'] == 2){echo 'selected';}?>>是</option></select></td>
                          <td><input type="text" style="width:100px;" onclick="WdatePicker()"name="startdate[]" value="<?=$tPI1Row['startdate']?>"/><small></small><input type="text" style="width:100px;" onclick="WdatePicker()"name="enddate[]" value="<?=$tPI1Row['enddate']?>"></td>
                          <td><input type="text" style="width:100px;" name="respondtime[]" onclick="WdatePicker({dateFmt:'HH:mm',skin:'whyGreen',quickSel:['<?=date('H:i',(time()+30*60))?>','<?=date('H:i',(time()+60*60))?>','<?=date('H:i',(time()+90*60))?>','<?=date('H:i',(time()+120*60))?>','<?=date('H:i',(time()+150*60))?>']})"value="<?=$tPI1Row['respond_time']?>"/></td>
                          <td><select name="remind_type[]">
                                <option value="1" <?if($tPI1Row['plan_type'] == 1){echo 'selected';}?>>铃声</option>
                                <option value="2" <?if($tPI1Row['plan_type'] == 2){echo 'selected';}?>>震动</option>
                                </select></td>
                          <td><input type="text" name="descriptions[]" value="<?=empty($tPI1Row['description'])?$tPI1Row['descriptions']:$tPI1Row['description']?>"/></td>
                        </tr>
                        <?}?>
                     </tbody>
                 </table>
                </form>
                  </div>
                  <div>
                     <form method="post" class="myform"> 
                      <table class="table table-condensed">
                      <thead>
                        <tr>
                          <th>护理类型</th>
                          <th>是否显示</th>
                          <th>是否提醒</th>
                          <th>提醒日期</th>
                          <th>提醒时间</th>
                          <th>提醒方式</th>
                          <th>提醒内容</th>
                        </tr>
                     </thead>
                     <tbody>
                      <?foreach($tPIDatas2 as $tPI2Row){?>
                       <tr>
                          <td><input type="hidden" name="at" value="3"><input type="hidden" name="<?=$tPI2Row['num']?>">
                                <input type="hidden" name="pi_id[]" value="<?=$tPI2Row['pi_id']?>"><?=$tPI2Row['name']?></td>
                          <td><select name="is_show[]" style="width:80px;"><option value="1" <?if($tPI2Row['is_show'] == 1){echo 'selected';}?>>是</option><option value="2" <?if($tPI2Row['is_show'] == 2){echo 'selected';}?>>否</option></select></td>
                          <td><select name="status[]" style="width:80px;"><option value="1" <?if($tPI2Row['status'] == 1){echo 'selected';}?>>否</option><option value="2" <?if($tPI2Row['status'] == 2){echo 'selected';}?>>是</option></select></td>
                          <td><input type="text" style="width:100px;" onclick="WdatePicker()"name="startdate[]" value="<?=$tPI2Row['startdate']?>"/><small></small><input type="text" style="width:100px;" onclick="WdatePicker()"name="enddate[]" value="<?=$tPI2Row['enddate']?>"></td>
                          <td><input type="text" style="width:100px;" name="respondtime[]" onclick="WdatePicker({dateFmt:'HH:mm',skin:'whyGreen',quickSel:['<?=date('H:i',(time()+30*60))?>','<?=date('H:i',(time()+60*60))?>','<?=date('H:i',(time()+90*60))?>','<?=date('H:i',(time()+120*60))?>','<?=date('H:i',(time()+150*60))?>']})"value="<?=$tPI2Row['respond_time']?>"/></td>
                          <td><select name="remind_type[]"><option value="1" <?if($tPI2Row['plan_type'] == 1){echo 'selected';}?>>铃声</option><option value="2" <?if($tPI2Row['plan_type'] == 2){echo 'selected';}?>>震动</option></select></td>
                          <td><input type="text" name="descriptions[]" value="<?=empty($tPI2Row['description'])?$tPI2Row['descriptions']:$tPI2Row['description']?>"/></td>
                        </tr>
                        <?}?>
                     </tbody>
                 </table>
                </form>
                  </div>
                  <div>
                    <form class="myform" method="post">
                      <table class="table table-condensed">
                      <thead>
                        <tr>
                          <th>护理类型</th>
                          <th>是否显示</th>
                          <th>是否提醒</th>
                          <th>提醒日期</th>
                          <th>提醒时间</th>
                          <th>提醒方式</th>
                          <th>提醒内容</th>
                        </tr>
                     </thead>
                     <tbody>
                      <?foreach($tPIDatas3 as $tPI3Row){?>
                       <tr>
                          <td><input type="hidden" name="at" value="4"><input type="hidden" name="<?=$tPI3Row['num']?>">
                                <input type="hidden" name="pi_id[]" value="<?=$tPI3Row['pi_id']?>"><?=$tPI3Row['name']?></td>
                          <td><select name="is_show[]" style="width:80px;"><option value="1" <?if($tPI3Row['is_show'] == 1){echo 'selected';}?>>是</option><option value="2" <?if($tPI3Row['is_show'] == 2){echo 'selected';}?>>否</option></select></td>
                          <td><select name="status[]" style="width:80px;"><option value="1" <?if($tPI3Row['status'] == 1){echo 'selected';}?>>否</option><option value="2" <?if($tPI3Row['status'] == 2){echo 'selected';}?>>是</option></select></td>
                          <td><input type="text" style="width:100px;" onclick="WdatePicker()"name="startdate[]" value="<?=$tPI3Row['startdate']?>"/><small></small><input type="text" style="width:100px;" onclick="WdatePicker()"name="enddate[]" value="<?=$tPI3Row['enddate']?>"></td>
                          <td><input type="text" style="width:100px;" name="respondtime[]" onclick="WdatePicker({dateFmt:'HH:mm',skin:'whyGreen',quickSel:['<?=date('H:i',(time()+30*60))?>','<?=date('H:i',(time()+60*60))?>','<?=date('H:i',(time()+90*60))?>','<?=date('H:i',(time()+120*60))?>','<?=date('H:i',(time()+150*60))?>']})"value="<?=$tPI3Row['respond_time']?>"/></td>
                          <td><select name="remind_type[]"><option value="1" <?if($tPI3Row['plan_type'] == 1){echo 'selected';}?>>铃声</option><option value="2" <?if($tPI3Row['plan_type'] == 2){echo 'selected';}?>>震动</option></select></td>
                          <td><input type="text" name="descriptions[]" value="<?=empty($tPI3Row['description'])?$tPI3Row['descriptions']:$tPI3Row['description']?>"/></td>
                        </tr>
                        <?}?>
                     </tbody>
                 </table></form></div>
                  <div>
                    <form class="myform" method="post">
                      <table class="table table-condensed">
                      <thead>
                        <tr>
                          <th>护理类型</th>
                          <th>是否显示</th>
                          <th>是否提醒</th>
                          <th>提醒日期</th>
                          <th>提醒时间</th>
                          <th>提醒方式</th>
                          <th>提醒内容</th>
                        </tr>
                     </thead>
                     <tbody>
                      <?foreach($tPIDatas4 as $tPI4Row){?>
                       <tr>
                          <td><input type="hidden" name="at" value="4"><input type="hidden" name="<?=$tPI4Row['num']?>">
                                <input type="hidden" name="pi_id[]" value="<?=$tPI4Row['pi_id']?>"><?=$tPI4Row['name']?></td>
                          <td><select name="is_show[]" style="width:80px;"><option value="1" <?if($tPI4Row['is_show'] == 1){echo 'selected';}?>>是</option><option value="2" <?if($tPI4Row['is_show'] == 2){echo 'selected';}?>>否</option></select></td>
                          <td><select name="status[]" style="width:80px;"><option value="1" <?if($tPI4Row['status'] == 1){echo 'selected';}?>>否</option><option value="2" <?if($tPI4Row['status'] == 2){echo 'selected';}?>>是</option></select></td>
                          <td><input type="text" style="width:100px;" onclick="WdatePicker()"name="startdate[]" value="<?=$tPI4Row['startdate']?>"/><small></small><input type="text" style="width:100px;" onclick="WdatePicker()"name="enddate[]" value="<?=$tPI4Row['enddate']?>"></td>
                          <td><input type="text" style="width:100px;" name="respondtime[]" onclick="WdatePicker({dateFmt:'HH:mm',skin:'whyGreen',quickSel:['<?=date('H:i',(time()+30*60))?>','<?=date('H:i',(time()+60*60))?>','<?=date('H:i',(time()+90*60))?>','<?=date('H:i',(time()+120*60))?>','<?=date('H:i',(time()+150*60))?>']})"value="<?=$tPI4Row['respond_time']?>"/></td>
                          <td><select name="remind_type[]"><option value="1" <?if($tPI4Row['plan_type'] == 1){echo 'selected';}?>>铃声</option><option value="2" <?if($tPI4Row['plan_type'] == 2){echo 'selected';}?>>震动</option></select></td>
                          <td><input type="text" name="descriptions[]" value="<?=empty($tPI4Row['description'])?$tPI4Row['descriptions']:$tPI4Row['description']?>"/></td>
                        </tr>
                        <?}?>
                     </tbody>
                 </table></form></div>
                  <div>
                    <form method="post" class="myform">
                      <table class="table table-condensed">
                      <thead>
                        <tr>
                          <th>护理类型</th>
                          <th>是否显示</th>
                          <th>是否提醒</th>
                          <th>提醒日期</th>
                          <th>提醒时间</th>
                          <th>提醒方式</th>
                          <th>提醒内容</th>
                        </tr>
                        <!-- 喝水 start -->

                        <!-- 喝水 end -->
                     </tbody>
                 </table></form></div>
                  <div>
                    <form method="post" class="myform">
                      <table class="table table-condensed">
                      <thead>
                        <tr>
                          <th>护理类型</th>
                          <th>是否显示</th>
                          <th>是否提醒</th>
                          <th>提醒日期</th>
                          <th>提醒时间</th>
                          <th>提醒方式</th>
                          <th>提醒内容</th>
                        </tr>
                     </thead>
                     <tbody>
                       <!-- 翻身 start -->
                       <!-- 翻身 end -->
                     </tbody>
                 </table></form></div>

               </div>
            </div>
		</div>	
    </div>
    <script type="text/javascript" src="/layertwo-assets/js/jquery.min.js"></script>
     <script type="text/javascript" src="/layertwo-assets/js/personset-jq.js"></script>
     <script type="text/javascript" src="/plugins/datepicker/WdatePicker.js" charset="UTF-8"></script>
<script src="/plugins/SweetAlert/sweetalert.min.js"></script><!--alert插件-->
<script src="/js/jquery.form.js"></script><!--form表单插件-->
<script>
$(function(){
//提交
    var options={
        beforeSubmit : showRequest,    // 提交前的回调函数
        success : showResponse,    // 提交后的回调函数
        dataType : "json",    // html（默认）、xml、script、json接受服务器端返回的类型
        timeout : 3000    // 限制请求的时间，当请求大于3秒后，跳出请求
    }
    function showRequest(formData, jqForm, options){
        return true;
    }
    function showResponse(responseText,statusText){
            cg_alert_add(responseText,'/admin_senior','/admin_senior/plan?id=<?=$pId?>');
    }
    //$('#save').click(function(){
    $(document).keyup(function(event){
        if(event.keyCode == 13){
       $('.st').each(function(){
            if($(this).val() == ''){
                alert('特殊事件时间段或时间点不能为空');return false;    
            }
            return;
        });
        if($('.st').val() == ''){
            return;
        }
        $('.myform').each(function(){
            $(this).ajaxSubmit(options);
        });
        
        }
    });
    //});
    $('#search').click(function(){
        $('form').submit();
    });


});
function addDrink(){
    var drinkHtml = ('<tr><td>&nbsp;</td><td>喝水</td><input type="hidden" name="event_type[]" value="9"><td><select name="status[]"><option value="1">否</option><option value="2" selected>是</option></select></td><td><input type="text" style="width:100px;" class="st" onclick="WdatePicker();" name="startdate[]" value=""/><span>————</span><input type="text" style="width:100px;" class="st" onclick="WdatePicker();" name="enddate[]" value=""></td><td><input type="text" style="width:100px;" class="st" name="respondtime[]" value=""/></td><td><select name="remind_type[]"><option value="1">铃声</option><option value="2">震动</option></select></td><td><input type="text" name="descriptions[]" value="请喂老人喝水"/></td><td><button type="button" class="deleteEvent btn btn-blue" onclick="$(this).parent().parent().remove();">—</button></td></tr>');
    $('.addDrink').parent().parent().after(drinkHtml);
}
function addFanshen(){
    var fanshenHtml = ('<tr><td>&nbsp;</td><td>翻身</td><input type="hidden" name="event_type[]" value="23"><td><select name="status[]"><option value="1">否</option><option value="2" selected>是</option></select></td><td><input type="text" style="width:100px;" class="st" onclick="WdatePicker();" name="startdate[]" value=""/><span>————</span><input type="text" style="width:100px;" class="st" onclick="WdatePicker();" name="enddate[]" value=""></td><td><input type="text" style="width:100px;" class="st" name="respondtime[]" value=""/></td><td><select name="remind_type[]"><option value="1">铃声</option><option value="2">震动</option></select></td><td><input type="text" name="descriptions[]" value="请帮助老人翻身"/></td><td><button type="button" class="deleteEvent btn btn-blue" onclick="$(this).parent().parent().remove();">—</button></td></tr>');
    $('.addFanshen').parent().parent().after(fanshenHtml);
}
$('#search').click(function(){
    $('form').submit();
});
/*获取地址栏参数*/
function GetQuery(key){
	var search = location.search.slice(1);//得到get方式提交的查询字符串
	var arr = search.split("&");
	for(var i = 0; i < arr.length; i++){
		var ar = arr[i].split("=");
		if(ar[0] == key){
			return ar[1];
		}
	}
}
function cg_alert_add(obj,list_url,add_url){
    if(obj.status == 1){
        swal({
            title: obj.msg,
            confirmButtonText:'继续添加',
            confirmButtonColor: "#DD6B55",
            showCancelButton: true,
            cancelButtonText:'返回列表',
            type: "success",
        },function(isConfirm){
            if (isConfirm) {
                location.href = add_url;
            }else{
                location.href = list_url;
            }
        });
    }else{
        swal(obj.msg,'','error');
    }

}
function cg_alert_edit(obj,list_url,edit_url){
    if(obj.status == 1){
        swal({
            title: obj.msg,
            confirmButtonText:'继续修改',
            confirmButtonColor: "#DD6B55",
            showCancelButton: true,
            cancelButtonText:'返回列表',
            type: "success",
        },function(isConfirm){
            if (isConfirm) {
                location.href = edit_url;
            }else{
                location.href = list_url;
            }
        });
    }else{
        swal(obj.msg,'','error');
    }

}
function cg_confirm_del(del_url,jump_url){
    swal({
            title: '您确定要删除吗？',
            text:'删除之后不能恢复',
            type: "warning",
            showCancelButton: true,
            confirmButtonColor: "#DD6B55",
            confirmButtonText:'确定',
            closeOnConfirm: false,
            cancelButtonText:'取消'
        },
        function(isConfirm){
            if(isConfirm){
                window.obj = '';
                $.ajax({
                    url: del_url,
                    dataType: "json",
                    async:false,
                    success: function (obj) {
                        window.obj = obj;
                    }
                });

                if(window.obj.status == 1){
                    swal({title:"删除成功!", type:"success"},function(){
                        location.href = jump_url;
                    });
                }else{
                    swal({title:window.obj.msg, type:"error"});
                }
            }
        });
}
</script>
    
</body>
</html>
